package co.fitstart.coach.entity.message;

import java.util.List;

import com.demo2do.core.wechat.corp.message.CorpMessage;
import com.demo2do.core.wechat.corp.message.CorpMessageStruct.CorpMessageStructBuilder;
import com.demo2do.core.wechat.corp.message.CorpMessageType;
import com.demo2do.core.wechat.corp.message.CorpTextMessage;

public class MessageMapper {
    
    private Target target;
    
    private List<String> targerIds;
    
    private int agentid;
    
    private CorpMessageType corpMessageType;
    
    private String message;
    
    public MessageMapper() {
    }
    
    /**
     * 
     * @param message
     * @param targetIds
     * @param agentid
     * @param target
     * @param corpMessageType
     */
    public MessageMapper(String message, List<String> targetIds, int agentid, Target target, CorpMessageType corpMessageType) {
        this.message = message;
        this.targerIds = targetIds;
        this.agentid = agentid;
        this.target = target;
        this.corpMessageType = corpMessageType;
    }
    
    /**
     * 
     * @return
     */
    public CorpMessageStructBuilder initBuilder() {
        
        CorpMessageStructBuilder builder = new CorpMessageStructBuilder(this.corpMessageType, this.agentid);
        
        if(this.target.isUser()) {
            builder.toUsers(this.targerIds);
        }
        
        return builder;
    }
    
    /**
     * 
     * @return
     */
    public CorpMessage initCorpMessgae() {
        
        CorpMessage  corpMessage = null;
        
        if(this.corpMessageType.equals(CorpMessageType.TEXT)) {
             corpMessage = new CorpTextMessage(this.message);
        }
        
        return corpMessage;
    }

    /**
     * @return the target
     */
    public Target getTarget() {
        return target;
    }

    /**
     * @return the targerIds
     */
    public List<String> getTargerIds() {
        return targerIds;
    }

    /**
     * @return the agentid
     */
    public int getAgentid() {
        return agentid;
    }

    /**
     * @return the corpMessageType
     */
    public CorpMessageType getCorpMessageType() {
        return corpMessageType;
    }

    /**
     * @return the message
     */
    public String getMessage() {
        return message;
    }

    /**
     * @param target the target to set
     */
    public void setTarget(Target target) {
        this.target = target;
    }

    /**
     * @param targerIds the targerIds to set
     */
    public void setTargerIds(List<String> targerIds) {
        this.targerIds = targerIds;
    }

    /**
     * @param agentid the agentid to set
     */
    public void setAgentid(int agentid) {
        this.agentid = agentid;
    }

    /**
     * @param corpMessageType the corpMessageType to set
     */
    public void setCorpMessageType(CorpMessageType corpMessageType) {
        this.corpMessageType = corpMessageType;
    }

    /**
     * @param message the message to set
     */
    public void setMessage(String message) {
        this.message = message;
    }
}
